package com.flute.framework.index.fieldbuilder;

import org.apache.lucene.document.Field;

import com.flute.framework.index.fieldbuilder.AbstractFieldBuilder;
import com.flute.tools.data.DataRecord;
import com.flute.tools.util.StringUtil;

public abstract class AbstractLuceneFieldBuilder extends AbstractFieldBuilder {

	@Override
	public Object buildField(DataRecord record) {
		String field = getDataField();
		String value = record.getFieldValue(field);
		if (value == null) {
			value = "";
		}
		if (getFieldStore() != Field.Store.YES) {
			value = StringUtil.getStandardString(value);
		}
		value = process(value);

		return new Field(docField, value, getFieldStore(), getFieldIndex());
	}

	public abstract Field.Index getFieldIndex();

	public abstract Field.Store getFieldStore();

	public abstract String process(String string);

}
